<script setup>
// 替换为你的图标库路径

import { Button, Dropdown, Menu, Popconfirm, Space } from 'ant-design-vue';

import Icon from '#/components/Icons';
import { $t } from '@vben/locales';
// 接收父组件传递的属性和事件
defineProps({
  row: { type: Object, required: true },
  showDataManagement: { type: Boolean, default: false }, // 新增的属性，用于控制是否显示数据管理按钮
  disabled: { type: Boolean, default: false },
});

const emit = defineEmits(['edit', 'delete']);

// 处理编辑按钮点击事件
function handleEdit(row) {
  emit('edit', row);
}

// 处理删除按钮点击事件
function handleDelete(row) {
  emit('delete', row);
}
</script>

<template>
  <Space>
    <Button :disabled="disabled" type="primary" @click="handleEdit(row)">
      <template #icon>
        <span class="anticon">
          <Icon icon="ri:file-edit-line" />
        </span>
      </template>
      {{$t('page.common.Edit')}}
    </Button>
    <Popconfirm
      :disabled="disabled"
      :cancel-text="$t('page.common.No')"
      :ok-text="$t('page.common.Yes')"
      :title="$t('page.common.Confirm Delete')"
      @confirm="handleDelete(row)"
    >
      <Button :disabled="disabled" danger type="primary">
        <template #icon>
          <span class="anticon">
            <Icon icon="ri:delete-bin-line" />
          </span>
        </template>
        {{$t('page.common.Delete')}}
      </Button>
    </Popconfirm>
    <Dropdown v-if="showDataManagement">
      <Button :disabled="disabled" type="link">
        <template #icon>
          <span class="anticon">
            <Icon icon="ri:more-fill" />
          </span>
        </template>
      </Button>
      <template #overlay>
        <Menu>
          <slot name="menuContent"></slot>
        </Menu>
      </template>
    </Dropdown>
  </Space>
</template>
